#!/usr/bin/python
import os
import sys

from ivic.core import Config, project_path
from ivic.core import Logging
from ivic.vsched import Model
from ivic.vsched.Controller import JobDispatcher

def main():
    logger = Logging.get_logger('ivic.vsched.CmdMain', format = log_format)
    
    config = Config.load(project_path('/etc/ivic/vsched.yaml'))
    Session = Model.get_ScopedSession(config['connect_string'])
    jobdispatcher = JobDispatcher(
        Session, 
        thread_num = config['thread_num'],
        debug_soap = config['debug_soap']
    )
    jobdispatcher.start()
    
    while True:
        print 'press `q` to quit'
    
        try:
            cmd = raw_input()
        except:
            break
    
        if cmd == 'q':
            break
        try:
            lvl = int(cmd)
            logger.setLevel(lvl)
        except:
            pass
    
    jobdispatcher.stop()
    jobdispatcher.join()
